﻿Imports System.Data.SqlClient
Imports System.Configuration
Public Class Form_dangnhap
    Dim dem As Integer = 0
    Private Sub cmd_ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_ok.Click
         Dim cmd As New SqlCommand
        cmd.Connection = conn
        cmd.CommandText = "sp_DangNhap"
        cmd.CommandType = CommandType.StoredProcedure

        cmd.Parameters.AddWithValue("@taikhoan", txt_taikhoan.Text)
        cmd.Parameters.AddWithValue("@matkhau", txt_matkhau.Text)

        Dim kq As Integer = cmd.ExecuteScalar
        If kq = 1 Then
            dangnhap = txt_taikhoan.Text
            Form_Main.Show()
            Me.Hide()
            txt_matkhau.Clear()
            txt_taikhoan.Clear()

        Else
            lb_thongbao.Text = "Thông tin đăng nhập không đúng"
            dem += 1
            If dem = 3 Then
                MsgBox("Bạn đăng nhập sai quá 3 lần", , "Thông Báo")
                Me.Close()
            End If
        End If
    End Sub

    Private Sub Form_dangnhap_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        conn.Open()
    End Sub
End Class
